/**
 * Created by 小敏哥 on 2017/8/15.
 * vip减免栏
 */
import React, {Component} from 'react';
import style from './index.scss';

class VipDiscount extends Component {
    constructor(props) {
        super(props);
    }

    static propTypes = {
        couponDiscount: React.PropTypes.number,//当前优惠券折扣
        isVip: React.PropTypes.bool,//是否为车务卡用户
        vipDiscount: React.PropTypes.number,//车务卡折扣
    };

    //车务卡使用框选择
    chooseVipDiscount(type) {
        //是否使用了优惠券
        let hasDiscount = this.props.couponDiscount > 0;
        //优惠券优先，使用优惠券时禁用会员卡
        let normalClass = hasDiscount ? style.vipDiscountInfo + ' ' + style.unUserd : style.vipDiscountInfo;
        switch (type) {
            //使用车务卡
            case 'normal':
                return <div className={normalClass}>
                    <div className={style.vipDiscountLeft}>
                        <div>
                            <span className={style.title}>VIP车务卡减免</span>
                        </div>
                    </div>
                    <div className={style.vipDiscountRight}>{'立减' + this.props.vipDiscount + '元'}</div>
                </div>;
            case 'none':
                return '';
        }
    }


    renderVipDiscount() {
        //是否为vip
        var isVip = this.props.isVip;

        if (isVip) {
            return this.chooseVipDiscount('normal');
        }
        else {
            return this.chooseVipDiscount('none');
        }

    }

    render() {
        return <div className={style.vipDiscount}>
            {this.renderVipDiscount()}
        </div>
    }

}


export default VipDiscount